define(['jquery'], function ($) {
    Fast.config.toastr.timeOut = 5000000;
    // 连接成功
    $(top).on('GoeasyConnetcted', function (e) {
        top.Goeasy.subscribe({
            channel: 'admin',
            onMessage: function (message) {
              var content = JSON.parse(message.content);
              console.log("ok");
                //处理数据示例
                Toastr.success(content.msg); //显示消息
                speechSynthesis.speak(new SpeechSynthesisUtterance(content.msg)); //语音读取文字
                // var table = $("#table");
                // table.bootstrapTable('refresh',{}); //刷新订单表
                
            }
        });
    });
    // 连接失败
    $(top).on('GoeasyConnetFailed', function (error) {

    });
    // 连接断开
    $(top).on('GoeasyDisconneted', function (e) {

    });

    // 前台收到广播消息
    $(top).on('GoeasyUserCommon', function (e, content) {
        Toastr.success("前台收到广播消息:" + content);
    });

    // 前台收到用户消息
    $(top).on('GoeasyUserMsg', function (e, content) {
        Toastr.success("前台收到用户消息:" + content);
    });

    // 后台收到广播消息
    $(top).on('GoeasyAdminCommon', function (e, content) {
        Toastr.success("后台收到广播消息:" + content);
    });

    // 后台收到用户消息
    $(top).on('GoeasyAdminMsg', function (e, content) {
        // Toastr.success("后台收到用户消息:" + content);
        Toastr.success(content.msg);
        speechSynthesis.speak(new SpeechSynthesisUtterance(content.msg)); //语音读取文字
    });


});